package com.mysql.study.test.controller;

import com.mysql.study.test.entity.User;
import com.mysql.study.test.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping
public class UserController {

    @Autowired
    private UserMapper userMapper;

    @GetMapping("/{name}/list")
    public List<User> list(@PathVariable("name") String name) {
        if (name.equals("master")) {
            return userMapper.getList1();
        } else {
            return userMapper.getList();
        }
    }
}
